package net.xdclass.config;

import lombok.Data;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.Exchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Data
public class RabbitMQConfig {

// add 队列
	private String shortLinkAddLinkQueue = "short_link.add.link.queue";
	private String shortLinkAddMappingQueue = "short_link.add.mapping.queue";

	private String shortLinkAddEventExchange = "short_link.add.exchange";

	private String shortLinkAddLinkBindingKey = "short_link.add.link.*.routing.key";
	private String shortLinkAddMappingBindingKey = "short_link.add.*.mapping.routing.key";

	private String shortLinkAddRoutingKey="short_link.add.link.mapping.routing.key";

	@Bean
	public Exchange getAddExchange() {
		return new TopicExchange(shortLinkAddEventExchange, true, false);
	}

	@Bean
	public Queue getShortLinkAddLinkQueue() {
		return new Queue(shortLinkAddLinkQueue);
	}

	@Bean
	public Queue getShortLinkAddMappingQueue() {
		return new Queue(shortLinkAddMappingQueue);
	}

	@Bean
	public Binding getShortLinkAddLinkBinding() {
		return new Binding(shortLinkAddLinkQueue, Binding.DestinationType.QUEUE, shortLinkAddEventExchange, shortLinkAddLinkBindingKey, null);
	}
	@Bean
	public Binding getShortLinkAddMappingBinding() {
		return new Binding(shortLinkAddMappingQueue, Binding.DestinationType.QUEUE, shortLinkAddEventExchange, shortLinkAddMappingBindingKey, null);
	}

	// del队列信息
	private String shortLinkDelLinkQueue = "short_link.del.link.queue";
	private String shortLinkDelMappingQueue = "short_link.del.mapping.queue";
	private String shortLinkDelEventExchange = "short_link.del.exchange";
	private String shortLinkDelLinkBindingKey = "short_link.del.link.*.routing.key";
	private String shortLinkDelMappingBindingKey = "short_link.del.*.mapping.routing.key";
	private String shortLinkDelRoutingKey="short_link.del.link.mapping.routing.key";

	@Bean
	public Exchange getDelExchange() {
		return new TopicExchange(shortLinkDelEventExchange, true, false);
	}

	@Bean
	public Queue getshortLinkDelLinkQueue() {
		return new Queue(shortLinkDelLinkQueue);
	}

	@Bean
	public Queue getshortLinkDelMappingQueue() {
		return new Queue(shortLinkDelMappingQueue);
	}

	@Bean
	public Binding getshortLinkDelLinkBinding() {
		return new Binding(shortLinkDelLinkQueue, Binding.DestinationType.QUEUE, shortLinkDelEventExchange, shortLinkDelLinkBindingKey, null);
	}

	@Bean
	public Binding getshortLinkDelMappingBinding() {
		return new Binding(shortLinkDelMappingQueue, Binding.DestinationType.QUEUE, shortLinkDelEventExchange, shortLinkDelMappingBindingKey, null);
	}
	// update 队列
	private String shortLinkUpdateLinkQueue = "short_link.update.link.queue";
	private String shortLinkUpdateMappingQueue = "short_link.update.mapping.queue";
	private String shortLinkUpdateEventExchange = "short_link.update.exchange";
	private String shortLinkUpdateLinkBindingKey = "short_link.update.link.*.routing.key";
	private String shortLinkUpdateMappingBindingKey = "short_link.update.*.mapping.routing.key";
	private String shortLinkUpdateRoutingKey="short_link.update.link.mapping.routing.key";

	@Bean
	public Exchange getUpdateExchange() {
		return new TopicExchange(shortLinkUpdateEventExchange, true, false);
	}

	@Bean
	public Queue getshortLinkUpdateLinkQueue() {
		return new Queue(shortLinkUpdateLinkQueue);
	}

	@Bean
	public Queue getshortLinkUpdateMappingQueue() {
		return new Queue(shortLinkUpdateMappingQueue);
	}

	@Bean
	public Binding getshortLinkUpdateLinkBinding() {
		return new Binding(shortLinkUpdateLinkQueue, Binding.DestinationType.QUEUE, shortLinkUpdateEventExchange, shortLinkUpdateLinkBindingKey, null);
	}

	@Bean
	public Binding getshortLinkUpdateMappingBinding() {
		return new Binding(shortLinkUpdateMappingQueue, Binding.DestinationType.QUEUE, shortLinkUpdateEventExchange, shortLinkUpdateMappingBindingKey, null);
	}

}
